package com.example.mall.order.app.service;

import com.example.mall.common.service.AbstractService;
import com.example.mall.order.app.cmd.CreateOrderCmd;
import com.example.mall.order.domain.model.Order;
import com.example.mall.order.infr.mapper.OrderMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author Mickey
 * @since 2022/4/22
 **/
@Service
@AllArgsConstructor
public class OrderAppService extends AbstractService {

    private final OrderMapper orderMapper;

    public Long create(CreateOrderCmd createOrder) {
        return creatorFor(orderMapper)
                .instance(createOrder::converterToOrder)
                .update(Order::calculate)
                .call()
                .getId();
    }

}
